package com.naiterui.ehp.bs.consult.service;

import com.naiterui.common.repository.page.PageParamVO;
import com.naiterui.common.repository.page.PageVO;
import com.naiterui.ehp.bp.bo.consult.VideoConsultBO;
import com.naiterui.ehp.bp.bo.consult.VideoConsultRecordBO;
import com.naiterui.ehp.bp.bo.groupConsult.GroupConsultPreSignBO;
import com.naiterui.ehp.bp.bo.groupConsult.GroupConsultSignCallbackBO;
import com.naiterui.ehp.bp.bo.recommend.RecomPrescriptionBO;
import com.naiterui.ehp.bp.support.exception.BusinessException;
import com.naiterui.ehp.bs.consult.dto.VideoConsultDTO;
import com.naiterui.ehp.bs.consult.vo.DoctorConsultDetailVO;
import com.naiterui.ehp.bs.consult.vo.DoctorConsultListVO;
import com.naiterui.ehp.bs.consult.vo.GroupConsultApplyVO;
import com.naiterui.ehp.bs.consult.vo.GroupConsultListVO;
import com.naiterui.ehp.bs.consult.vo.GroupConsultOpinionConfirmVO;
import com.naiterui.ehp.bs.consult.vo.GroupConsultOpinionVO;
import com.naiterui.ehp.bs.consult.vo.PatientConsultRecordVO;
import com.naiterui.ehp.bs.consult.vo.RefusalReasonVO;
import com.naiterui.ehp.bs.consult.vo.UserInfoVO;
import com.naiterui.ehp.bs.consult.vo.VideoConsultConfigVO;
import com.naiterui.ehp.bs.consult.vo.VideoConsultMessageListVO;
import com.naiterui.ehp.bs.consult.vo.VideoConsultRoomConfigVO;
import org.springframework.data.domain.Pageable;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * 视频问诊
 *
 * @author yangfuya
 * @version 1.0
 * @date 2021-02-25 18:43
 **/
public interface IVideoConsultService {

    /**
     * 根据患者id、医生id和就诊人id获取视频问诊信息
     *
     * @param patientId
     * @param doctorId
     * @return
     */
    VideoConsultBO getVideoConsult(Long patientId, Long doctorId);

    /**
     * 根据id列表批量获取问诊信息
     *
     * @param videoConsultIds
     * @return
     */
    List<VideoConsultBO> getVideoConsults(List<Long> videoConsultIds);

    /**
     * 根据订单号查询视频问诊信息
     *
     * @param orderSn
     * @return
     */
    VideoConsultBO getVideoConsultByOrderSn(String orderSn);

    /**
     * 根据id获取问诊信息
     *
     * @param videoConsultId
     * @return
     */
    VideoConsultBO getVideoConsultById(Long videoConsultId);

    /**
     * 添加或者修改视频问诊
     *
     * @param videoConsultBO
     * @return
     */
    VideoConsultBO saveOrUpdate(VideoConsultBO videoConsultBO);

    /**
     * 接受和进入房间
     *
     * @param videoConsultDTO
     * @return
     * @throws BusinessException
     */
    List<VideoConsultMessageListVO> accept(VideoConsultDTO videoConsultDTO) throws BusinessException;

    /**
     * 获取配置信息
     *
     * @param videoConsultId 视频问诊id
     * @param userId         用户id
     * @return
     * @throws BusinessException
     */
    VideoConsultConfigVO getAppIdAndKey(Long videoConsultId, String userId) throws BusinessException;

    /**
     * 上传文件
     *
     * @param roomId
     * @param file
     * @return
     */
    String uploadFile(String roomId, MultipartFile file);

    /**
     * 发送群组消息
     *
     * @param roomId       房间id
     * @param isDoctorSend 是否医生发送：1.医生 0.患者
     * @param userId       发送人
     * @param file         文件
     * @throws BusinessException
     */
    void sendGroupMsg(Integer roomId, Integer isDoctorSend, String userId, MultipartFile file) throws BusinessException;

    /**
     * 取消视频咨询
     *
     * @param videoConsultId
     * @throws BusinessException
     */
    void cancelVideoConsult(Long videoConsultId) throws BusinessException;

    /**
     * 结束问诊
     *
     * @param roomId
     * @param diagnosis
     */
    void finish(Integer roomId, String diagnosis);

    /**
     * 患者咨询记录
     *
     * @param patientId
     * @param doctorId
     * @param pageParamVO
     * @return
     */
    PageVO<PatientConsultRecordVO> patientConsultRecord(Long patientId, Long doctorId, PageParamVO pageParamVO);

    /**
     * 拒绝视频问诊
     *
     * @param videoConsultDTO
     * @throws BusinessException
     */
    void refuse(VideoConsultDTO videoConsultDTO) throws BusinessException;

    /**
     * 医生接诊列表
     *
     * @param doctorId
     * @param status
     * @param pageable
     * @return
     */
    PageVO<DoctorConsultListVO> doctorConsultList(Long doctorId, Integer status, Pageable pageable) throws BusinessException;

    /**
     * 待接诊数量
     *
     * @param doctorId
     * @return
     */
    Integer toTreatNum(Long doctorId);

    /**
     * 拒诊原因列表
     *
     * @return
     */
    List<RefusalReasonVO> refusalReasonList();

    /**
     * 获取图片列表
     *
     * @param videoConsultId
     * @return
     */
    List<String> getImageList(Long videoConsultId);

    /**
     * 医生接诊详情
     *
     * @param videoConsultId
     */
    DoctorConsultDetailVO doctorConsultDetail(Long videoConsultId) throws BusinessException;

    /**
     * 发送中断通知
     *
     * @param roomId
     */
    void sendDiscontinueMsg(Integer roomId);

    /**
     * 修改状态
     *
     * @param roomId
     * @param talkTime
     * @param videoConsultStatus
     */
    void updateVideoConsultStatus(Integer roomId, Long talkTime, Integer videoConsultStatus, String userId);

    /**
     * 患者记录测试用接口（进行中和中断状态的信息）
     *
     * @param patientId
     * @param pageParam
     * @return
     */
    PageVO<PatientConsultRecordVO> patientConsultRecordTest(Long patientId, PageParamVO pageParam);

    /**
     * 进入房间接口
     *
     * @param videoConsultId
     * @return
     * @throws BusinessException
     */
    List<VideoConsultMessageListVO> inRoom(Long videoConsultId) throws BusinessException;

    /**
     * 上传永久素材
     * @param file 素材文件
     * @throws BusinessException
     */
    void uploadThumbMedia(MultipartFile file);

    /**
     * 视频咨询房间配置
     * @param roomId
     * @param userId
     */
    VideoConsultRoomConfigVO videoConsultRoomConfig(Integer roomId, String userId) throws BusinessException;

    /**
     * 根据userId获取用户信息
     * @param userId
     * @return
     * @throws BusinessException
     */
    UserInfoVO getUserInfo(String userId, Integer roomId) throws BusinessException;

    /**
     * 小程序首页查询用户视频问诊记录列表
     * @param patientId
     * @param page
     * @param num
     * @return
     * @throws BusinessException
     */
    PageVO<VideoConsultRecordBO> consultVideoList(Long patientId, int page, int num) throws BusinessException;

    /**
     * 依据状态获取视频问诊数量
     * @param doctorId
     * @param videoConsultStatus
     * @return
     * @throws BusinessException
     */
    Integer getCountByStatus(Long doctorId, Integer videoConsultStatus) throws BusinessException ;

    /**
     * （医生端1.1优化）
     * 根据医生id获取视频问诊订单
     * @param doctorId
     * @return
     * @throws BusinessException
     */
    List<VideoConsultBO> getOrderByDoctorId(Long doctorId) throws BusinessException ;

    /**
     * 获取病例pdf
     *
     * @param videoConsultId
     * @return
     */
    String getCasePdf(Long videoConsultId) throws BusinessException;

    /**
     * 处方列表 g g
     *
     * @param videoConsultId
     * @return
     */
    List<RecomPrescriptionBO> recomList(Long videoConsultId) throws BusinessException;

    /**
     * 分页获取已结束问诊信息
     *
     * @param page
     * @param inquirerIds
     * @return
     */
    PageVO<PatientConsultRecordVO> getFinishedVideoConsultsPage(PageParamVO page, List<Long> inquirerIds);

    /**
     * 根据视频问诊ID查询问诊信息
     *
     * @param videoConsultId
     * @return
     */
    PatientConsultRecordVO getPatientConsultRecord(Long videoConsultId);

    /**
     * 暂时离开
     *
     * @param roomId
     * @param doctorId
     */
    void leave(Integer roomId, Long doctorId);
    
    /**
     * 会诊申请信息
     *
     * @param videoConsultId
     * @param doctorId
     * @return
     */
    GroupConsultApplyVO groupConsultInfo(Long videoConsultId, Long doctorId) throws BusinessException;

    /**
     * 会诊申请提交
     *
     * @param groupConsultApplyVO
     * @return
     */
    void groupConsultApply(GroupConsultApplyVO groupConsultApplyVO) throws BusinessException;

    /**
     * 结束会诊
     *
     * @param roomId
     * @return
     */
    void groupConsultFinish(Integer roomId) throws BusinessException;

    /**
     * 会诊列表
     *
     * @param doctorId
     * @param pageParam
     * @return
     */
    PageVO<GroupConsultListVO> groupConsultList(Long doctorId, PageParamVO pageParam) throws BusinessException;

    /**
     * 会诊明细信息
     *
     * @param videoConsultId
     * @return
     */
    GroupConsultListVO groupConsultDetail(Long videoConsultId) throws BusinessException;

    /**
     * 会诊意见填写
     *
     * @param groupConsultOpinionVO /
     * @return
     */
    GroupConsultPreSignBO groupConsultOpinion(GroupConsultOpinionVO groupConsultOpinionVO) throws BusinessException;

    /**
     * @param groupConsultOpinionConfirmVO
     * @throws BusinessException
     */
    void groupConsultOpinionConfirm(GroupConsultOpinionConfirmVO groupConsultOpinionConfirmVO) throws BusinessException;

    /**
     * @param groupConsultSignCallbackBO
     * @throws BusinessException
     */
    void groupConsultOpinionCallback(GroupConsultSignCallbackBO groupConsultSignCallbackBO) throws BusinessException;

}
